package conc.testme;

import java.util.Calendar;
import java.util.GregorianCalendar;

@SuppressWarnings("serial")
public class Data extends GregorianCalendar {
	
	public Data (int dia, int mes, int ano){
		super(ano, mes - 1, dia);
	}
	
	public Data(){
		super();
	}
	
	//data no formato dd/mm/aaaa
	public Data (String data){
		super();
		int dia, mes, ano;
		dia = ((new Integer(data.substring(0, data.indexOf("/"))).intValue()));
		mes = ((new Integer(data.substring(data.indexOf("/") + 1, data.indexOf("/", data.indexOf("/") + 1))).intValue()) - 1);
		ano = ((new Integer(data.substring(
				data.lastIndexOf("/") + 1, data.length())).intValue()));
		
		set(DAY_OF_MONTH, dia);
		set(MONTH, mes);
		set(YEAR, ano);
		
	}
	
	public String toString(){
		return  get(Calendar.DAY_OF_MONTH)+"/"+ (get(Calendar.MONTH) + 1)+"/"+ get(Calendar.YEAR);		
	
	}
	
	public int getMes(){
		return get(Calendar.MONTH) + 1;	
	}
	
	public int getDia(){
		return get(Calendar.DAY_OF_MONTH);	
	}
	
	

}
